import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class 加减 {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static int MAXN = 100001;
    public static int n,k;
    public static long[] arr = new long[MAXN];
    public static long[] sum = new long[MAXN];
    public static int ans;
    public static void main(String[] args) throws IOException {
        // 前置工作
        n = in.nextInt();
        k = in.nextInt();
        ans = 1;
        for (int i = 1; i <= n; i++) {
            arr[i] = in.nextLong();
        }
        // 进行排序
        Arrays.sort(arr,1,n + 1);
        // 前缀和进行优化
        for (int i = 1; i <= n; i++) {
            sum[i] += sum[i - 1] + arr[i];
        }
        // 滑动窗口
        int left = 1;
        for (int right = 1; right <= n; right++) {
            // 先判断花费有没有超过 k, 如果超过 k 就将滑动窗口往左边收缩, 知道花费小于等于 cost
            long cost = find(left,right);
            while (cost > k) {
                cost = find(++left,right);
            }
            // 每次进行取最大值
            ans = Math.max(ans,right - left + 1);
        }
        out.println(ans);
        out.close();
    }

    private static long find(int left, int right) {
        // 找出花费, 根据图片理解
        int mid = (left + right) / 2;
        return arr[mid] * (mid - left) - (sum[mid - 1] - sum[left - 1]) + sum[right] - sum[mid] - (right - mid) * arr[mid];
    }

    public static class Read {
        StringTokenizer st = new StringTokenizer("");
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String next() throws IOException {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}
